home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene 96
/
Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso
/
misc
/
coding
/
ct_xmp15
/
cppexam.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-15
|
2KB
|
113 lines
#include <string.h>
#include <ctype.h>
#include <process.h>
#include <conio.h>
#include <io.h>
#include <fcntl.h>
#include <stdlib.h>
#include "mxmplay.h"
void setcurshape(unsigned short);
#pragma aux setcurshape parm [cx] modify [ax] = "mov ax,0103h" "int 10h"
void main()
{
cputs("mxm player example (c) '95/96 Niklas Beisert / pascal\r\n\n");
char cmdline[128];
char *cmdp=cmdline;
getcmd(cmdline);
while (isspace(*cmdp))
cmdp++;
char *cmdpe=cmdp;
while (*cmdpe&&!isspace(*cmdpe))
cmdpe++;
cmdpe=0;
if (!*cmdp)
{
cputs("argument error\r\n");
return;
}
char fname[_MAX_FNAME];
char path[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
_splitpath(cmdp, drive, dir, fname, 0);
_makepath(path, drive, dir, fname, ".mxm");
int f=open(path, O_RDONLY|O_BINARY);
if (f<0)
{
cputs("file error\r\n");
return;
}
unsigned char *mxmmem=new unsigned char [filelength(f)+0x4000];
if (!mxmmem)
{
cputs("malloc error\r\n");
return;
}
cputs("loading file...");
read(f, mxmmem+0x4000, filelength(f));
close(f);
cputs("\r\nuploading samples...");
if (!xmpInit(mxmmem+0x4000, xmpGetGUSPort(xmpGetEnvPtrDPMI(_psp)), mxmmem, 65536, MXMINTMODEDOS))
{
cputs("player error\r\n");
return;
}
cputs("\r\nplaying module...\r\n");
xmpPlay(0);
setcurshape(0x2000);
while (!kbhit())
{
unsigned short pos=xmpGetPos();
unsigned long tim=xmpGetTimer()/1193046;
unsigned char sync=xmpGetSync();
char str[20];
str[0]=13;
str[1]="0123456789ABCDEF"[(tim>>12)&0xF];
str[2]="0123456789ABCDEF"[(tim>>8)&0xF];
str[3]="0123456789ABCDEF"[(tim>>4)&0xF];
str[4]="0123456789ABCDEF"[(tim>>0)&0xF];
str[5]=' ';
str[6]="0123456789ABCDEF"[(pos>>12)&0xF];
str[7]="0123456789ABCDEF"[(pos>>8)&0xF];
str[8]=' ';
str[9]="0123456789ABCDEF"[(pos>>4)&0xF];
str[10]="0123456789ABCDEF"[(pos>>0)&0xF];
str[11]=' ';
str[12]="0123456789ABCDEF"[(sync>>4)&0xF];
str[13]="0123456789ABCDEF"[(sync>>0)&0xF];
str[14]=0;
cputs(str);
}
setcurshape(0xD0E);
cputs("\r\n");
unsigned long t0=xmpGetTimer();
while (1)
{
signed long t1=(xmpGetTimer()-t0);
if (t1>596523)
break;
if (t1>0)
xmpSetVolume(64-t1/9321);
}
xmpStop();
delete mxmmem;
while (kbhit())
getch();
}